//
//  LCVersionViewController.m
//  EnterpriseCloud
//
//  Created by 东亨 on 2017/7/11.
//  Copyright © 2017年 lichao. All rights reserved.
//

#import "LCVersionViewController.h"
#import "LCLableCell.h"
#import "LCVersionCell.h"
#import "CountHeight.h"
#import "LCHeadView.h"
static NSString *cellidentifier = @"LCLableCell";
static NSString *cellidentifier1 = @"LCVersionCell";
@interface LCVersionViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong,nonatomic)NSDictionary  *attributes;
@property (copy,nonatomic)NSString   *contextStr;
@end

@implementation LCVersionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setBarTitle:@"版本说明"];
    [self loadCustomeView];
}
- (void)loadCustomeView
{
    _contextStr = @"更清楚的了解楼宇企业信息\n促进政企之间的互联互动\n建立政企沟通的桥梁！\n";
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tableView.tableFooterView = [[UIView alloc]init];
    [_tableView registerNib:[UINib nibWithNibName:@"LCLableCell" bundle:nil] forCellReuseIdentifier:cellidentifier];
    [_tableView registerNib:[UINib nibWithNibName:@"LCVersionCell" bundle:nil] forCellReuseIdentifier:cellidentifier1];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.lineSpacing = 4;// 字体的行间距
    _attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:13],NSParagraphStyleAttributeName:paragraphStyle};
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0)
    {
        return 40;
    }
    else
    {
        return 0.1;
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0)
    {
        LCHeadView *headView = [[LCHeadView alloc]initWithTitle:@"版本说明"];
        return headView;
    }
    else
    {
        return nil;
    }
}
#pragma mark -UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
    {
        LCVersionCell *cell = [tableView dequeueReusableCellWithIdentifier:cellidentifier1];
        cell.versionLbl.text = APP_VERSION;//版本号
        return cell;
    }
    else
    {
        LCLableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellidentifier];
        cell.topHeight.constant = 2;
        NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:_contextStr attributes:_attributes];
        cell.contextLbl.attributedText = attributeStr;
        return cell;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
    {
        return 57;
    }
    else
    {
        CGFloat height =  [CountHeight boundingRectWithwidth:SCREEN_WIDTH-30 attributes:_attributes context:_contextStr];
        return height+12;
    }
}

@end
